<?php

class Column {

	var $sName;
	var $oTable;
	var $sDataType;
	var $bIsPartOfPrimaryKey;
	var $bIsPartOfForeignKey;
	
	function Column ( &$oTable, $sName, $sDataType ) {
		$this->oTable    =& $oTable;
		$this->sName     =  $sName;
		$this->sDataType =  $sDataType;
		$this->bIsPartOfPrimaryKey = false;
		$this->bIsPartOfForeignKey = false;
	}
	
	function GetName() {
		return $this->sName;	
	} 

	function GetTableName() {
		if ( is_object( $this->oTable ) ) {
			return $this->oTable->GetName();
		}
		return null;
	}
	
	function GetDataType() {
		return $this->sDataType;	
	}
	
	function SetIsPartOfPrimaryKey() {
		$this->bIsPartOfPrimaryKey = true;	
	}
	
	function GetIsPartOfPrimaryKey() {
		return $this->bIsPartOfPrimaryKey;	
	}
	
	function SetIsPartOfForeignKey() {
		$this->bIsPartOfForeignKey = true;	
	}
	
	function GetIsPartOfForeignKey() {
		return $this->bIsPartOfForeignKey;
	}

	function GetPropertiesAsString() {
		$aProperties = array();
		if ( $this->GetIsPartOfPrimaryKey() ) {
			$aProperties[] = 'PK';
		}
		if ( $this->GetIsPartOfForeignKey() ) {
			$aProperties[] = 'FK';
		}
		return implode( ', ', $aProperties );
	}
}

?>
